﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Web;

namespace Devfw.OpenAuth
{
    /// <summary>
    /// access token Url Response
    /// </summary>
    [Serializable()]
    public class AccessTokenResponse : NameValueCollection
    {
        public AccessTokenResponse( string query )
            : base( HttpUtility.ParseQueryString( query ) )
        {
        }

        public AccessTokenResponse( NameValueCollection nvcQuery )
            : base( nvcQuery )
        {
        }
        
        /// <summary>
        /// Access Token
        /// </summary>
        public string oauth_token
        {
            get
            {
                return this["oauth_token"];
            }
            set
            {
                this["oauth_token"] = value;
            }
        }

        /// <summary>
        /// Access Token Secret
        /// </summary>
        public string oauth_token_secret
        {
            get
            {
                return this["oauth_token_secret"];
            }
            set
            {
                this["oauth_token_secret"] = value;
            }
        }

        /// <summary>
        /// UserID
        /// </summary>
        public string user_id
        {
            get
            {
                var userID = this["user_id"];
                if (string.IsNullOrEmpty(userID))
                    userID = this["douban_user_id"];

                return userID;
            }
            set
            {
                this["user_id"] = value;
            }
        }
    }
}
